Skip to content

fix(db): respect vector extension config in per-bank index migration#832

Merged
nicoloboschi merged 2 commits intomainfrom
fix/per-bank-vector-index-type
Apr 1, 2026
Merged

fix(db): respect vector extension config in per-bank index migration#832
nicoloboschi merged 2 commits intomainfrom
fix/per-bank-vector-index-type

Conversation

@nicoloboschi
Copy link
Copy Markdown
Collaborator

Summary

  • Migration d5e6f7a8b9c0 (introduced in v0.4.18) hardcoded USING hnsw when creating per-bank partial vector indexes, ignoring HINDSIGHT_API_VECTOR_EXTENSION. Banks that existed before upgrading to v0.4.18 got HNSW indexes even when pgvectorscale (DiskANN) or vchord was configured.
  • Fix the original migration to read the vector extension config via HINDSIGHT_API_VECTOR_EXTENSION env var
  • Add new migration a4b5c6d7e8f9 that detects mismatched per-bank indexes and recreates them with the correct type. The migration is skipped entirely when the configured extension is pgvector (default), since those indexes are already correct.

Test plan

  • Verify migration chain is valid (single head: a4b5c6d7e8f9)
  • Test with HINDSIGHT_API_VECTOR_EXTENSION=pgvector — new migration should be a no-op
  • Test with HINDSIGHT_API_VECTOR_EXTENSION=pgvectorscale on a DB with existing HNSW per-bank indexes — indexes should be recreated as DiskANN
  • Test with HINDSIGHT_API_VECTOR_EXTENSION=vchord on a DB with existing HNSW per-bank indexes — indexes should be recreated as vchordrq
  • Verify recall queries still use the correct indexes after migration

Migration d5e6f7a8b9c0 hardcoded HNSW when creating per-bank partial
vector indexes, ignoring HINDSIGHT_API_VECTOR_EXTENSION. This caused
banks migrated from pre-v0.4.18 to get HNSW indexes even when
pgvectorscale (DiskANN) or vchord was configured.

- Fix the original migration to read the vector extension config
- Add migration a4b5c6d7e8f9 to detect and recreate mismatched indexes
  (skipped entirely when extension is pgvector, since those are correct)
@nicoloboschi nicoloboschi merged commit 4fd7c5d into main Apr 1, 2026
91 of 94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant